package com.smart.web.controller.system;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smart.common.annotation.Log;
import com.smart.common.core.controller.BaseController;
import com.smart.common.core.domain.AjaxResult;
import com.smart.common.enums.BusinessType;
import com.smart.common.core.domain.R;
import com.smart.system.domain.GasRecord;
import com.smart.system.service.IGasRecordService;
import com.smart.common.utils.poi.ExcelUtil;
import com.smart.common.core.page.TableDataInfo;

/**
 * 气体记录Controller
 * 
 * @author smart
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/system/gasRecord")
@Api(tags = "气体记录")
public class GasRecordController extends BaseController
{
    @Autowired
    private IGasRecordService gasRecordService;

    /**
     * 查询气体记录列表
     */
    @ApiOperation(value = "查询气体记录列表")
    //@PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo<GasRecord> list(GasRecord gasRecord)
    {
        startPage();
        List<GasRecord> list = gasRecordService.list(Wrappers.query(gasRecord));
        return getDataTable(list);
    }

    /**
     * 导出气体记录列表
     */
    @ApiOperation(value = "导出气体记录列表")
    //@PreAuthorize("@ss.hasPermi('system:record:export')")
    @Log(title = "气体记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GasRecord gasRecord)
    {
        List<GasRecord> list = gasRecordService.list(Wrappers.query(gasRecord));
        ExcelUtil<GasRecord> util = new ExcelUtil<GasRecord>(GasRecord.class);
        util.exportExcel(response, list, "气体记录数据");
    }

    /**
     * 获取气体记录详细信息
     */
    @ApiOperation(value = "获取气体记录详细信息")
    //@PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{id}")
    public R<GasRecord> getInfo(@PathVariable("id") Integer id)
    {
        return R.ok(gasRecordService.getById(id));
    }

}
